home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / thesource6.dms / thesource6.adf / Source / Compression / hcompress.lha / hcompress / vms / hdecompress.com < prev    next >
Encoding:
Text File  |  1992-04-24  |  4.0 KB  |  148 lines

  1. $! hdecompress.com
  2. $!
  3. $! VMS command file to do H-transform image de-compression for a list of files.
  4. $! *.xxx_H files are replaced by *.xxx.
  5. $!
  6. $! R. White, 20 April 1992
  7. $!
  8. $! determine where this procedure lives (assume that the executable files
  9. $! are in this same directory)
  10. $!
  11. $ shellfile=f$parse(f$environment("procedure"),,,,"NO_CONCEAL")-"]["
  12. $ cdir=f$extract(0,f$locate("]",shellfile),shellfile) + "]"
  13. $ prgnam=f$parse(shellfile,,,"NAME")
  14. $!
  15. $ echo:=write sys$output
  16. $ hd:=$'cdir'hdecomp
  17. $!
  18. $ if p1.eqs.""
  19. $ then
  20. $    echo "Usage: ",prgnam," [options] files... [options] files..."
  21. $    echo "  where options are:"
  22. $    echo "     -s to enable smoothing"
  23. $    echo "     -u to disable smoothing (default)"
  24. $    echo "     -k to keep the compressed file (default)"
  25. $    echo "     -r to remove the compressed file"
  26. $    echo "     -o raw | net | fits | hhh to specify the output image format"
  27. $    echo "        The default output format is raw (= hhh) unless the original"
  28. $    echo "        image was FITS format, in which case the default is fits"
  29. $    echo "        format."
  30. $    echo ""
  31. $    echo "     Compressed files are named *.*_H; decompressed are named *.*."
  32. $    echo "     _H should be explicitly specified at the end of the file names."
  33. $    exit
  34. $ endif
  35. $!
  36. $ remove=0
  37. $ smooth=""
  38. $ format=""
  39. $ nextformat=0
  40. $ p=1
  41. $ ploop:
  42. $   parm = p'p
  43. $   if parm.eqs."" then exit        ! all done
  44. $   if nextformat.eqs.1
  45. $   then
  46. $      format=parm            ! set output format
  47. $      nextformat=0
  48. $      goto endploop
  49. $   endif
  50. $   if parm.eqs."-O"
  51. $   then
  52. $      nextformat=1            ! next parameter will be output format
  53. $      goto endploop
  54. $   endif
  55. $   if parm.eqs."-R"
  56. $   then
  57. $      remove=1                ! remove original files
  58. $      goto endploop
  59. $   endif
  60. $   if parm.eqs."-K"
  61. $   then
  62. $      remove=0                ! keep original files
  63. $      goto endploop
  64. $   endif
  65. $   if parm.eqs."-S"
  66. $   then
  67. $      smooth="-s"            ! smooth images
  68. $      goto endploop
  69. $   endif
  70. $   if parm.eqs."-U"
  71. $   then
  72. $      smooth=""            ! don't smooth images
  73. $      goto endploop
  74. $   endif
  75. $!
  76. $! decompress the file(s) specified by this parameter
  77. $! use f$search to allow the use of wildcards in file specifications
  78. $!
  79. $   compfile=f$search(parm,1)        ! get file name
  80. $   if compfile.eqs.""
  81. $   then
  82. $      echo prgnam,": ",compfile,": No such file"
  83. $      goto endploop
  84. $   endif
  85. $!
  86. $! save name of first file to correct the stupid behavior of f$search
  87. $! when the file argument does not contain a wildcard character
  88. $!
  89. $   firstfile=compfile
  90. $ floop:
  91. $      cext=f$parse(compfile,,,"TYPE")
  92. $!
  93. $! make sure file name ends with "_H"
  94. $!
  95. $      if f$extract(f$length(cext)-2,2,cext).nes."_H"
  96. $      then
  97. $         echo prgnam,": ",compfile,": Filename does not end in _H"
  98. $         goto endfloop
  99. $      endif
  100. $!
  101. $! remove "_H" from end of extension to get original file name
  102. $!
  103. $      dext=f$extract(0,f$length(cext)-2,cext)
  104. $      datafile=f$parse(dext+";",compfile,,,"SYNTAX_ONLY")    ! original name
  105. $!
  106. $! if original file still exists, we'll rely on VMS to create a new version
  107. $!
  108. $!
  109. $! perform decompression
  110. $!
  111. $      echo datafile
  112. $      on warning then continue
  113. $      if format.nes.""
  114. $      then
  115. $         define/user sys$input  'compfile'
  116. $         define/user sys$output 'datafile'
  117. $         hd -v 'smooth' -o 'format'
  118. $      else
  119. $         define/user sys$input  'compfile'
  120. $         define/user sys$output 'datafile'
  121. $         hd -v 'smooth'
  122. $      endif
  123. $      if $status.eq.1                    ! check for success
  124. $      then
  125. $         if remove.eq.1 then delete 'compfile'        ! delete compressed file
  126. $      else
  127. $         echo prgnam,": error, ",compfile," not decompressed"
  128. $         delete 'datafile'                ! delete decomp file
  129. $      endif
  130. $ endfloop:
  131. $!
  132. $! get next file name
  133. $!
  134. $! be careful: f$search returns the same name every time if there are
  135. $! no wildcard characters in the argument (dumb)
  136. $!
  137. $      compfile=f$search(parm,1)
  138. $      if compfile.nes.firstfile
  139. $      then
  140. $         if compfile.nes."" then goto floop
  141. $      endif
  142. $!
  143. $! go to next parameter
  144. $!
  145. $ endploop:
  146. $   p = p+1
  147. $   goto ploop
  148.